/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.beautycenter.ModelosTabela;

import br.com.beautycenter.Funcionalidades.Validacoes;
import java.awt.Component;
import javax.swing.JTable;
import javax.swing.SwingConstants;
import javax.swing.table.DefaultTableCellRenderer;

/**
 *
 * @author magelinha
 */
public class JTableCellRenderer extends DefaultTableCellRenderer {

    public JTableCellRenderer() {
        super();
    }
    
    @Override
    public void setValue(Object aValue){
        Object valor = aValue;
        if(aValue != null && aValue instanceof Number){
            Number temp = (Number)aValue;
            valor = Validacoes.formatoMoeda.format(temp.doubleValue());
        }
        
        super.setValue(valor);
    }
    
    
    @Override
    public Component getTableCellRendererComponent(JTable table, Object value,boolean isSelected, boolean hasFocus,
            int row, int column){
        
        this.setHorizontalAlignment(CENTER);
        return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
    }
    
}
